/*
 * @(#)cn.design.pattern.ocp 2020/4/8/0008
 *
 * Copy Right@ 人人译视界
 */


package cn.design.pattern.ocp;

/**
 * <pre>
 * @author tuwei
 *
 * @version 0.9
 *
 * 修改版本: 0.9
 * 修改日期: 2020/4/8/0008
 * 修改人 :  tuwei
 * 修改说明: 初步完成
 * 复审人 ：
 * </pre>
 */
public class Ocp {
	public static void main(String[] args) {
		GraphicEditor graphicEditor = new GraphicEditor();
		graphicEditor.drawRectangle(new Rectangle());
		graphicEditor.drawShape(new Circle());
	}
}

class GraphicEditor {
	public void drawShape(Shape r) {
		if (r.m_type == 1) {
			drawRectangle(r);
		}
		else if (r.m_type == 2) {
			drawCircle(r);
		}
	}

	private void drawCircle(Shape r) {
		System.out.println("绘制圆形");
	}

	public void drawRectangle(Shape r) {
		System.out.println("绘制矩形");
	}
}

class Shape {
	int m_type;
}

class Rectangle extends Shape {
	Rectangle() {
		super.m_type = 1;
	}
}

class Circle extends Shape {
	Circle() {
		super.m_type = 2;
	}
}